<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/layui/layui_2/layui/css/layui.css"
	media="all" />
</head>
<body>
	<div id='recovery_emp_div'>
		<form class="layui-form" action="" id="recoveryEmpForm" lay-filter="recovery_emp_form" method="post">
			<br/>
			<input type="hidden" value="${emp.e_id }" name="e_id" />
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">员工姓名:</label>
					<div class="layui-input-inline">
						<input type="text" name="e_truename" lay-verify="required"
							autocomplete="off" class="layui-input" value="${emp.e_truename }">
					</div>
				</div>
			</div>

			<div class="layui-form-item">
                <label class="layui-form-label">所在部门:</label>
                	<div class="layui-input-inline">
                        <select name="dept.p_id" id="deptSelect" lay-filter="dept_select">
                    </select>
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" id="confim" lay-submit="" lay-filter="recoveryConfim">确定</button>
				</div>
			</div>
		</form>
	</div>
	<script
		src="${pageContext.request.contextPath }/layui/layui_2/layui/layui.js"></script>
	<script>
		layui.use([ 'element', 'table', 'jquery', 'layer', 'form','upload' ],function() {
			var $ = layui.jquery,
				layer = layui.layer,
				form = layui.form,
				upload = layui.upload;
			
			//动态添加部门选项
		    $.post('${pageContext.request.contextPath}/deptAction_getByName',{},function(data){
			    for(var i = 0;i< data.length;i++){
				    var id = data[i].p_id;
				    var name = data[i].p_name;
				    $('#deptSelect').append("<option value="+id+">"+name+"</option>");
				}
				form.render('select');
			})
			    
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			
			//监听提交
			form.on('submit(recovery_emp_form)', function(data) {
				$.post("${pageContext.request.contextPath}/empAction_recovery.action",
						////将form表单序列化成json格式
	                    $("#recoveryEmpForm").serialize(),
	                    function (data) {
							parent.location.href = '${pageContext.request.contextPath}/page_emp_recoveryEmp.action';
	                        parent.layer.close(index);
	            });
				return false;
			});
		});
		
	</script>
</body>
</html>